﻿Public Class Refresh_Control
    Dim Down_True As Boolean
    Public Sub Drag_Check(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        'Checks to make sure control is breing dragged.
        Down_True = True
        Dim box_size As New Size(32, 25)
        Dim box As New Rectangle(Cursor.Position, box_size)
        Scavenger.CreateGraphics.DrawImage(My.Resources.Btn_Base_Hover, box.X, box.Y, 32, 25)
    End Sub
    Public Sub Drag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        'Create duplicate stand in for the control. Actual control stays stationary
        Dim Mouse_Pos As New Point(Cursor.Position.X - 16, Cursor.Position.Y - 32)
        If Down_True = True Then
            Scavenger.CreateGraphics.Clear(Scavenger.BackColor)
            Dim box_size As New Size(32, 25)
            Dim box As New Rectangle(Mouse_Pos, box_size)
            Scavenger.CreateGraphics.DrawImage(My.Resources.Btn_Base_Hover, box.X, box.Y, 32, 25)
        End If
    End Sub
    Public Sub Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        'Checks for a hit across the entire tab board.
        Dim I As Integer
        I = 0
        Dim Mouse_Pos As New Point(Cursor.Position.X - 16, Cursor.Position.Y - 32)
        For Each tab As TabPage In Scavenger.TabControl1.TabPages
            Dim tabrec As Rectangle = Scavenger.TabControl1.GetTabRect(I)
            Dim hitbox As New Rectangle(tabrec.X, tabrec.Y + 61, tabrec.Width, tabrec.Height)
            If hitbox.Contains(Mouse_Pos) Then
                Dim SB As ScavengerBrowser = Scavenger.TabControl1.TabPages.Item(I).Tag
                SB.Refresh()
                I = I + 1
            Else
                I = I + 1
            End If
        Next
        Scavenger.Refresh()
        Down_True = False
    End Sub
End Class
